﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.Workshop;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.Workshop
{
    public class WorkshopItemService: IService<WorkshopItem>
    {
        private readonly GenericRepository<WorkshopItem> _workshopItemRepository;
        private readonly IUnitOfWork _unitOfWork;

        public WorkshopItemService(IUnitOfWork unitOfWork, GenericRepository<WorkshopItem> workshopItemRepository)
        {
            this._workshopItemRepository = workshopItemRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<WorkshopItem> GetAllElements()
        {
            return _workshopItemRepository.GetAll();
        }

        public WorkshopItem GetElementById(int id)
        {
            return _workshopItemRepository.GetById(id);
        }

        public void CreateElement(WorkshopItem entity)
        {
            _workshopItemRepository.Insert(entity);
        }

        public void UpdateElement(WorkshopItem entity)
        {
            _workshopItemRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _workshopItemRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
